/**
 * 判断是否有指定的操作权限
 * @param {array} permissions 权限数组
 * @param {string} option
 *
 * @example isHavePermission('add', pagePermissions, dataPermissions)
 */
export const isHavePermission = (option, ...permissions) => {
    if(permissions.some(p => !p || (p && p.length === 0)))
        return false;
    return permissions.every(p => p.includes(option));
};

export const hasPermissions = (data, name) => Array.isArray(data) && data.length > 0 && data.some(item => item === name);
